package jcommand.sample;

import java.awt.event.KeyEvent;

import jcommand.*;
import jcommand.event.Application;

/**
 * Sample Program of JCommand. <br>
 * <br>
 * 1. Open Internet Explorer. <br>
 * 2. Speak out "I just open the internet explorer." <br>
 * 3. Speak out "I am going to switch your application." <br>
 * 4. Switch Application (Pressing ALT+TAB) <br>
 * 
 * @author Kenneth Lo
 * @since 1.0.0
 * 
 */
public class JCommandDemoExampleOne {

	public static void main(String[] args) {
		try {

			// Create the command to launch the internet explorer
			Command c1 = new Command("Internet");
			c1.addAction(Action.Launch(Application.INTERNET_EXPLORER));

			// Create the command to speak Hello
			Command c2 = new Command("Speak1");
			c2.addAction(Action.TTS("I just open the internet explorer."));

			Command c3 = new Command("Speak2");
			c3.addAction(Action.TTS("I am going to switch your application."));

			Command c4 = new Command("Switch");
			c4.addAction(Action.KeyHoldAndClick(KeyEvent.VK_ALT,
					KeyEvent.VK_TAB));

			// Create the command set
			CommandSet cs = new CommandSet();

			// Add the command in the command set
			cs.addCommand(c1);
			cs.addCommand(c2);
			cs.addCommand(c3);
			cs.addCommand(c4);

			// Execute the commands
			cs.runAllCommands(1000);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
